package cLog

import (
	"fmt"

	"github.com/sirupsen/logrus"
)

type (
	StdoutHook struct {
		Format   LogFormat `json:"format"`
		Colorful bool      `json:"colorful"`
	}
)

func (e StdoutHook) GetFormat() LogFormat {
	return e.Format
}

func (e StdoutHook) GetColorful() bool {
	return e.Colorful
}

func (e StdoutHook) Levels() []logrus.Level {
	return logrus.AllLevels
}

func (e StdoutHook) Fire(entry *logrus.Entry) error {
	out, err := format(entry, e)
	if err != nil {
		return err
	}
	fmt.Print(out, "\n")

	return nil
}
